/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.nanosn.linux;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 *
 * @author selkhateeb
 */
public class Linux
{
    // <editor-fold defaultstate="collapsed" desc="cat">
    public static void cat(File file)
    {
        String thisLine;

        try
        {
            FileInputStream fin = new FileInputStream(file);

            BufferedReader input = new BufferedReader(new InputStreamReader(fin));

            while ((thisLine = input.readLine()) != null)
            {
                System.out.println(thisLine);
            }
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }

    public static void cat(String fileName)
    {
        File file = new File(fileName);
        cat(file);
    }
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="ls">
    public static List<String> ls(File directory)
    {
        return new ArrayList<String>(Arrays.asList(directory.list()));
    }
    // </editor-fold>

}
